package kyssion.leetcode.num101_150;

import kyssion.leetcode.util.ListNode;

public class code141_环形列表 {
    public boolean hasCycle(ListNode head) {
        ListNode one = head;
        ListNode two = head;
        while (true) {
            one = head.next;
            if (two.next != null) {
                two = two.next.next;
            } else {
                two = null;
            }
            if(one==null||two==null){
                break;
            }
            if (one == two) {
                return true;
            }
        }
        return false;
    }
}
